
export default  {

    /**
     * 深度拷贝
     * @param obj
     * @return {*}
     */
    deepClone(obj){
        let newObject;
        if(obj === null) {
            return null;
        }
        else if (!(obj instanceof Object)) {
            return obj;
        }
        else if (obj instanceof Date) {
            return new Date(obj);
        }
        else if (obj instanceof Function) {
            return Object.assign(obj);
        }
        else if (obj instanceof RegExp) {
            return new RegExp(obj);
        }
        else if (obj instanceof Array){
            newObject = [];
            for(let item of obj) {
                newObject.push(this.deepClone(item));
            }
        }
        else {
            newObject = Object.assign(Object.create(Object.getPrototypeOf(obj)),obj);
            for(let key of Object.keys(obj)) {
                if(newObject[key] !== obj) {
                    newObject[key] = this.deepClone(obj[key]);
                }else {
                    newObject[key] = newObject;
                }
            }
        }
        return newObject;
    }
};
